<%@include file="/WEB-INF/common/taglibs.jsp"%>
<link rel="STYLESHEET" type="text/css"
	href="${ctx}/resources/plugin/dhtmlxTree/dhtmlxtree.css">
<script src="${ctx}/resources/plugin/dhtmlxTree/dhtmlxcommon.js"></script>
<script src="${ctx}/resources/plugin/dhtmlxTree/dhtmlxtree.js"></script>
<script src="${ctx}/resources/plugin/dhtmlxTree/ext/dhtmlxtree_json.js"></script>
<script type="text/javascript">

$(document).ready(function() {
	tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
 	tree.setSkin('dhx_skyblue');
	tree.setImagePath("${ctx}/resources/plugin/dhtmlxTree/imgs/csh_vista/");
//	tree.enableCheckBoxes(1);
	tree.enableDragAndDrop(1);

	
	
//	tree.setOnOpenHandler(tonopen);
//	tree.attachEvent("onOpenEnd", function(nodeId, event) {
	  //  doLog("An id of open item is " + nodeId);
//	});
//	tree.setOnClickHandler(tonclick);
//	tree.setOnCheckHandler(toncheck);
//	tree.setOnDblClickHandler(tondblclick);
	tree.setDragHandler(tondrag);
//tree.setXMLAutoLoading("tree3.json");
	tree.setDataMode("json");
	tree.loadJSON("${ctx}/channel/tree/");

});
	

function tondrag(id, id2) {
var child = id;
var parent = id2;
var url = "${ctx}"+"/channel/"+id+"/edit/"+parent;
$.ajax({
		url : url,
		type : "PUT",
		dataType : "json",
		success : function(data){		
		if(data && data.state && (data.state.indexOf("ERROR") != -1)){
		johnny.success(data.message);
 		return;
		}else{
			johnny.info("update email successfully");
			}
		}
	});
	return true;
  //  return confirm("Do you want to move node " + tree.getItemText(id) + " to item " + tree.getItemText(id2) + "?");
};

</script>

<div class="row-fluid">
<div class="span8">
<div class="centerContent">
<div class="span6">

<div id="treeboxbox_tree" class="span12"></div>



</div>
</div>
</div>
</div>

